<template>
  <van-nav-bar fixed placeholder @click-left="handleLeftClick" @click-right="handleRightClick">
    <template #left>
      <van-icon name="arrow-left" color="#000" v-if="leftArrow" size="17"></van-icon>
      <span v-if="leftText">{{ title }}</span>
    </template>
    <template #right>
      <van-icon name="search" color="#000" size="19"></van-icon>
    </template>
  </van-nav-bar>
</template>

<script lang="ts" setup>
import { useMyRouters } from '@/router';

defineProps({
  title: {
    type: String,
    default: ''
  },
  leftArrow: {
    type: Boolean,
    default: false
  },
  leftText: {
    type: Boolean,
    default: true
  }
});

const { router } = useMyRouters();
const handleLeftClick = () => {
  router.back();
};
const handleRightClick = () => {
  router.push({
    path: '/search'
  });
};

</script>

<style lang="less" scoped>
.van-nav-bar__content {
  span {
    font-size: 16px;
    padding-left: 5px;
  }
}
</style>
